from flask import Flask
from config import config_map
from flask_sqlalchemy import SQLAlchemy
import pymysql
pymysql.install_as_MySQLdb()

db = SQLAlchemy()

# 采用工厂模式创建app实例
def create_app(config_name='develop'):
    app = Flask(__name__)
    # 加载配置类
    config = config_map[config_name]
    app.config.from_object(config)

    db.init_app(app)

    # 注册蓝图
    from . import view
    app.register_blueprint(view.blue,url_prefix='/show')

    return app
